<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>管理系统</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <?php if($form_parm_arr['static_html']){ ?>
    {$form_parm_arr['static_html']|raw}
  <?php }else{ ?>
    {:widget_st('layui','css')}
    {:widget_st('jq','js')}
    {:widget_st('layui','js')}  
    {:widget_st('admin','css')}
    {:widget_st('laydate','js')}
    {:widget_st('webuploader')}
    {:widget_st('common','js')}
    {:widget_st('ueditor')}       
    {:widget_st('input-select')}    
  <?php } ?>

</head>
{:do_action('admin_head')}
<body>
  <?php $form_widget = new \app\common\widget\FormPro();  ?>
  <div class="layui-fluid">
      <div class="layui-row layui-col-space15">
        <form class="layui-form info_tj"  >
          <?php if(isset($res['id'])){ ?>
            <input type="hidden" name="id" value="{$res.id}">
            <input type="hidden" name="pid" value="{$res.pid}">
          <?php }else{ ?>
            <input type="hidden" name="pid" value="{$pid}">
          <?php }?>
          <?php if($form_parm_arr['form_parm'] && isset($form_parm_arr['form_parm']['ini']) && $form_parm_arr['form_parm']['ini']['zf_form_status']==1 ){ ?>

            {include file="public/form_parm_show"}
            {include file="public/widget_submit"}
          <?php }else{ ?>
            <!-- //默认表单 -->
            <div class="layui-col-md8">
              <div class="layui-card">
                <div class="layui-card-header">信息</div>
                <div class="layui-card-body">
                    <?php if(isset($res['id'])){ ?>
                      {$form_widget->form_input(['title'=>'名称','name'=>'name','data'=>$res['name'],'theme'=>2])|raw}
                      {$form_widget->form_textarea(['title'=>'描述','name'=>'summary','data'=>$res['summary'],'theme'=>2])|raw}
                      {$form_widget->form_input(['title'=>'链接','name'=>'url','data'=>$res['url'],'theme'=>2])|raw}
                      {$form_widget->filesystem_pic(['title'=>'图片(pc)','name'=>'pic','data'=>$res['pic'],'theme'=>3])|raw}
                      {$form_widget->filesystem_pic(['title'=>'图片(wap)','name'=>'pic_wap','data'=>$res['pic_wap'],'theme'=>3])|raw}
                      {$form_widget->form_input(['title'=>'图片alt','name'=>'alt_pic','data'=>$res['alt_pic'],'theme'=>2])|raw}
                      {$form_widget->form_input(['title'=>'排序','name'=>'sort','data'=>$res['sort'],'theme'=>2])|raw}
                      {$form_widget->form_radio(['title'=>'状态','name'=>'status','data'=>$res['status'],'parm_data'=>['0'=>'关闭','1'=>'开启'],'theme'=>2])|raw}
                      <div class="layui-form-item">
                        <div class="layui-input-block">
                          <a class="layui-btn layui-btn-sm" onclick="tijiao_data('/admin/rests/advert_edit')" >提交</a>
                        </div>
                      </div>
                    <?php }else{ ?>
                      {$form_widget->form_input(['title'=>'名称','name'=>'name','data'=>'','theme'=>2])|raw}
                      {$form_widget->form_textarea(['title'=>'描述','name'=>'summary','data'=>'','theme'=>2])|raw}
                      {$form_widget->form_input(['title'=>'链接','name'=>'url','data'=>'','theme'=>2])|raw}
                      {$form_widget->filesystem_pic(['title'=>'图片(pc)','name'=>'pic','data'=>'','theme'=>3])|raw}
                      {$form_widget->filesystem_pic(['title'=>'图片(wap)','name'=>'pic_wap','data'=>'','theme'=>3])|raw}
                      {$form_widget->form_input(['title'=>'图片alt','name'=>'alt_pic','data'=>'','theme'=>2])|raw}
                      {$form_widget->form_input(['title'=>'排序','name'=>'sort','data'=>'','theme'=>2])|raw}
                      {$form_widget->form_radio(['title'=>'状态','name'=>'status','data'=>1,'parm_data'=>['0'=>'关闭','1'=>'开启'],'theme'=>2])|raw}
                      
                      <div class="layui-form-item">
                        <div class="layui-input-block">
                          <a class="layui-btn layui-btn-sm" onclick="tijiao_data('/admin/rests/advert_add')" >提交</a>
                        </div>
                      </div>
                    <?php }?>

                </div>
              </div>
            </div>
          <?php } ?>
        </form>
      </div>
    </div>
</body>
</html>
{:do_action('admin_js')}

<script>
  layui.use(['form', 'upload'], function(){
     var $ = layui.$
     ,form = layui.form
     ,upload = layui.upload ;
 
     
     $('.tijiao').on("click",function(){
           var index = layer.load(2);
           var data = $(".info_tj input,.info_tj select,.info_tj textarea,.info_tj radio").serialize();      
           $.ajax({
               type:'post',
               data:data,
               dataType:'json',
               success:function(res){
                 if(res.result==1){
                   layer.msg(res.msg, {icon: 1});
                   setTimeout(function() {
                       if(res.msg.code==1){
                         window.location.reload();
                       }else{
                         window.parent.location.reload();
                       }
                   }, 2000);
                 }else{
                   layer.close(index);
                   layer.msg(res.msg, {icon: 2});
                 }   
               }
           })
       })
     
   })
   </script>